package com.ruoyi.btlfbreed.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.btlfbreed.domain.TbVaccinationRecords;
import com.ruoyi.btlfbreed.service.ITbVaccinationRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 疫苗使用登记Controller
 * 
 * @author ruoyi
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/btlfbreed/vaccinationRecords")
public class TbVaccinationRecordsController extends BaseController
{
    @Autowired
    private ITbVaccinationRecordsService tbVaccinationRecordsService;

    /**
     * 查询疫苗使用登记列表
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:vaccinationRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbVaccinationRecords tbVaccinationRecords)
    {
        startPage();
        List<TbVaccinationRecords> list = tbVaccinationRecordsService.selectTbVaccinationRecordsList(tbVaccinationRecords);
        return getDataTable(list);
    }

    /**
     * 导出疫苗使用登记列表
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:vaccinationRecords:export')")
    @Log(title = "疫苗使用登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbVaccinationRecords tbVaccinationRecords)
    {
        List<TbVaccinationRecords> list = tbVaccinationRecordsService.selectTbVaccinationRecordsList(tbVaccinationRecords);
        ExcelUtil<TbVaccinationRecords> util = new ExcelUtil<TbVaccinationRecords>(TbVaccinationRecords.class);
        util.exportExcel(response, list, "疫苗使用登记数据");
    }

    /**
     * 获取疫苗使用登记详细信息
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:vaccinationRecords:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(tbVaccinationRecordsService.selectTbVaccinationRecordsByRecordId(recordId));
    }

    /**
     * 新增疫苗使用登记
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:vaccinationRecords:add')")
    @Log(title = "疫苗使用登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVaccinationRecords tbVaccinationRecords)
    {
        return toAjax(tbVaccinationRecordsService.insertTbVaccinationRecords(tbVaccinationRecords));
    }

    /**
     * 修改疫苗使用登记
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:vaccinationRecords:edit')")
    @Log(title = "疫苗使用登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVaccinationRecords tbVaccinationRecords)
    {
        return toAjax(tbVaccinationRecordsService.updateTbVaccinationRecords(tbVaccinationRecords));
    }

    /**
     * 删除疫苗使用登记
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:vaccinationRecords:remove')")
    @Log(title = "疫苗使用登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(tbVaccinationRecordsService.deleteTbVaccinationRecordsByRecordIds(recordIds));
    }
}
